package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.BusDeviceArea;
import com.ruoyi.business.service.IBusDeviceAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设施农业-园区概况Controller
 * 
 * @author ruoyi
 * @date 2023-07-22
 */
@RestController
@RequestMapping("/device/area")
@Api(tags = "设施农业-园区概况")
public class BusDeviceAreaController extends BaseController
{
    @Autowired
    private IBusDeviceAreaService busDeviceAreaService;

    /**
     * 查询设施农业-园区概况列表
     */
    @GetMapping("/list")
    @ApiOperation("列表 ")
    public TableDataInfo list(BusDeviceArea busDeviceArea)
    {
        startPage();
        List<BusDeviceArea> list = busDeviceAreaService.selectBusDeviceAreaList(busDeviceArea);
        return getDataTable(list);
    }

    /**
     * 导出设施农业-园区概况列表
     */
    @PreAuthorize("@ss.hasPermi('device:area:export')")
    @Log(title = "设施农业-园区概况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusDeviceArea busDeviceArea)
    {
        List<BusDeviceArea> list = busDeviceAreaService.selectBusDeviceAreaList(busDeviceArea);
        ExcelUtil<BusDeviceArea> util = new ExcelUtil<BusDeviceArea>(BusDeviceArea.class);
        util.exportExcel(response, list, "设施农业-园区概况数据");
    }

    /**
     * 获取设施农业-园区概况详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:area:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busDeviceAreaService.selectBusDeviceAreaById(id));
    }

    /**
     * 新增设施农业-园区概况
     */
    @PreAuthorize("@ss.hasPermi('device:area:add')")
    @Log(title = "设施农业-园区概况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusDeviceArea busDeviceArea)
    {
        return toAjax(busDeviceAreaService.insertBusDeviceArea(busDeviceArea));
    }

    /**
     * 修改设施农业-园区概况
     */
    @PreAuthorize("@ss.hasPermi('device:area:edit')")
    @Log(title = "设施农业-园区概况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusDeviceArea busDeviceArea)
    {
        return toAjax(busDeviceAreaService.updateBusDeviceArea(busDeviceArea));
    }

    /**
     * 删除设施农业-园区概况
     */
    @PreAuthorize("@ss.hasPermi('device:area:remove')")
    @Log(title = "设施农业-园区概况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busDeviceAreaService.deleteBusDeviceAreaByIds(ids));
    }
}
